package com.sh.data.engine.domain.base.model.datax;

/**
 * @Auther: zigui.zdf @Date: 2018/10/12 11:09 @Description:数据源类型定义
 */
public enum DataxReaderAndWriter {
    MySQL("MySQL", "mysqlreader", "mysqlwriter"),
    MySQL8("MySQL8", "mysql8reader", "mysql8writer"),
    SQLServer("SQLServer", "sqlserverreader", "sqlserverwriter"),
    PostgreSQL("PostgreSQL", "postgresqlreader", "postgresqlwriter"),
    MatrixDB("MatrixDB", "postgresqlreader", "postgresqlwriter"),
    DB2("DB2", "rdbmsreader", "rdbmswriter"),
    Sap("Sap", "rdbmsreader", "rdbmswriter"),
    Oracle("Oracle", "oraclereader", "oraclewriter"),
    OpenTSDB("OpenTSDB", "opentsdbreader", "opentsdbwriter"),
    Hive("Hive", "hivereader", "hivewriter"),
    MaxCompute("MaxCompute", "maxcompute", "maxcompute"),
    Mongodb("Mongodb", "mongodbreader", "mongodbwriter"),
    Text("Text", "txtfilereader", "txtfilewriter"),
    GBase("GBase", "gbasereader", "gbasewriter"),
    Redis("Redis", "", "rediswriter"),
    Kylin("Kylin", "kylinreader", ""),
    CarbonData("CarbonData", "carbondatareader", "carbondatawriter"),
    ElasticSearch("ElasticSearch", "elasticsearchreader", "elasticsearchwriter"),
    LibrA("LibrA", "librareader", "librawriter"),
    FTP("FTP", "ftpfilereader", "ftpfilewriter"),
    SFTP("SFTP", "ftpfilereader", "ftpfilewriter"),
    Hdfs("Hdfs", "hdfsfilereader", "hdfsfilewriter"),
    HBase("HBase", "hbase11xreader", "hbase11xwriter"),
    DM("DM", "rdbmsreader", "rdbmswriter"),
    KINGBASE8("KINGBASE8", "rdbmsreader", "rdbmswriter"),
    Api("Api", "apireader", ""),
    WebService("WebService", "webservicereader", ""),
    TiDB("TiDB", "mysqlreader", "mysqlwriter"),
    AS400("AS400", "as400reader", "as400writer"),
    GPONLYCSV("GP", "", "gpwriter"),
    ;


    private String name;
    private String reader;
    private String writer;

    DataxReaderAndWriter(String name, String reader, String writer) {
        this.name = name;
        this.reader = reader;
        this.writer = writer;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getReader() {
        return reader;
    }

    public void setReader(String reader) {
        this.reader = reader;
    }

    public String getWriter() {
        return writer;
    }

    public void setWriter(String writer) {
        this.writer = writer;
    }

    public static String getReaderByName(String name) {
        return DataxReaderAndWriter.valueOf(name).getReader();
    }

    public static String getWriterByName(String name) {
        return DataxReaderAndWriter.valueOf(name).getWriter();
    }

    public static String getDsTypeByReader(String name) {
        if (name == null) {
            return null;
        }
        for (DataxReaderAndWriter value : DataxReaderAndWriter.values()) {
            if (value.getReader().equals(name)) {
                return value.getName();
            }
        }

        return null;
    }
}
